<?php
namespace Service\Controller;
use Think\Controller;
class AreaController extends Controller {
	public function index(){
		Vendor("taobaosdk.top.TopClient");
		Vendor('taobaosdk.lotusphp_runtime.Logger.Logger');
		Vendor("taobaosdk.top.RequestCheckUtil");
		Vendor('taobaosdk.top.request.AreasGetRequest');
		
		if(S('areas')){
		    $resp = S('areas');//从缓存中读取数据
		}else{
    		$c =  new \TopClient();
    		$c->appkey = C("WZ_KEY");
    		$c->secretKey = C("WZ_SECRET");
    		$c->format = 'json';
    		$req = new \AreasGetRequest;
    		$req->setFields("id,type,name");
    		$resp = $c->execute($req);
    		
    		S('areas',$resp,2592000);
		}
		$resp->code=200;
		header('Access-Control-Allow-Headers:x-requested-with,content-type');
		header("Access-Control-Allow-Origin: * ");
		$this->ajaxReturn(json_encode($resp));
	}
}